﻿using System;
using Microsoft.Practices.ObjectBuilder;
using System.Web.Services;
using SignalR;

namespace Locator.Admin.Views
{
    public partial class ScanStores : Microsoft.Practices.CompositeWeb.Web.UI.Page, IScanStoresView
    {
        private ScanStoresPresenter presenter;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.presenter.OnViewInitialized();
            }

            this.presenter.OnViewLoaded();
        }

        [CreateNew]
        public ScanStoresPresenter Presenter
        {
            get { return this.presenter; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value");

                this.presenter = value;
                this.presenter.View = this;
            }
        }

        [WebMethod]
        public static void Scan()
        {
            //var connection = Connection.GetConnection<Updates>();
            
            //connection.Broadcast("scanning");
        }

        protected void ScanButton_Click(object sender, EventArgs e)
        {
            //this.Presenter.OnScan();
            //var connection = Connection.GetConnection<Updates>();
            //connection.Broadcast("scanning");
        }

        public void SetResults(string results)
        {
            this.ResultsTextBox.Text = results;
        }

        public override void Dispose()
        {
            if (this.presenter != null)
            {
                this.presenter.Dispose();
            }

            base.Dispose();
        }

    }
}

